
package com.ankiang.mykeys;

import android.content.Context;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import java.util.List;

/**
 * Created by yetwish on 2015-05-11
 */

public class SearchAdapter extends ArrayAdapter<Object> {

    private int mResourceId;

    public SearchAdapter(Context context, int resourceId,
                       int textViewResourceId, List<Object> items) {
        super(context, resourceId, textViewResourceId, items);
        this.mResourceId = resourceId;
    }

    public View getView(AppCompatActivity act, int position, View convertView, ViewGroup parent) {
        Object item = getItem(position);
        LayoutInflater inflater = act.getLayoutInflater();
        View view = inflater.inflate(mResourceId, null);

        TextView text = (TextView) view.findViewById(R.id.search_item_info);
        text.setText(item.toString());
        return view;
    }
}